<?php

add_action('init','of_options');

if (!function_exists('of_options'))
{	function of_options()
	{
		//Access the WordPress Categories via an Array
		$of_categories 		= array();  
		$of_categories_obj 	= get_categories('hide_empty=0');
		foreach ($of_categories_obj as $of_cat) {
		    $of_categories[$of_cat->cat_ID] = $of_cat->cat_name;}
		$categories_tmp 	= array_unshift($of_categories, "Select a category:");    
	       
		//Access the WordPress Pages via an Array
		$of_pages 			= array();
		$of_pages_obj 		= get_pages('sort_column=post_parent,menu_order');    
		foreach ($of_pages_obj as $of_page) {
		    $of_pages[$of_page->ID] = $of_page->post_name; }
		$of_pages_tmp 		= array_unshift($of_pages, "Select a page:");       
	
		//Testing 
		$of_options_select 	= array("one","two","three","four","five"); 
		$of_options_radio 	= array("one" => "One","two" => "Two","three" => "Three","four" => "Four","five" => "Five");
		
		//Sample Homepage blocks for the layout manager (sorter)
		$of_options_homepage_blocks = array
		( 
			"disabled" => array (
				"placebo" 		=> "placebo", //REQUIRED!
				"block_one"		=> "Block One",
				"block_two"		=> "Block Two",
				"block_three"	=> "Block Three",
			), 
			"enabled" => array (
				"placebo" 		=> "placebo", //REQUIRED!
				"block_four"	=> "Block Four",
			),
		);


		//Stylesheets Reader
		$alt_stylesheet_path = LAYOUT_PATH;
		$alt_stylesheets = array();
		
		if ( is_dir($alt_stylesheet_path) ) 
		{
		    if ($alt_stylesheet_dir = opendir($alt_stylesheet_path) ) 
		    { 
		        while ( ($alt_stylesheet_file = readdir($alt_stylesheet_dir)) !== false ) 
		        {
		            if(stristr($alt_stylesheet_file, ".css") !== false)
		            {
		                $alt_stylesheets[] = $alt_stylesheet_file;
		            }
		        }    
		    }
		}


		//Background Images Reader
		$bg_images_path = get_stylesheet_directory(). '/images/bg/'; // change this to where you store your bg images
		$bg_images_url = get_template_directory_uri().'/images/bg/'; // change this to where you store your bg images
		$bg_images = array();
		
		if ( is_dir($bg_images_path) ) {
		    if ($bg_images_dir = opendir($bg_images_path) ) { 
		        while ( ($bg_images_file = readdir($bg_images_dir)) !== false ) {
		            if(stristr($bg_images_file, ".png") !== false || stristr($bg_images_file, ".jpg") !== false) {
		            	natsort($bg_images); //Sorts the array into a natural order
		                $bg_images[] = $bg_images_url . $bg_images_file;
		            }
		        }    
		    }
		}
		

		/*-----------------------------------------------------------------------------------*/
		/* TO DO: Add options/functions that use these */
		/*-----------------------------------------------------------------------------------*/
		
		//More Options
		$uploads_arr 		= wp_upload_dir();
		$all_uploads_path 	= $uploads_arr['path'];
		$all_uploads 		= get_option('of_uploads');
		$other_entries 		= array("Select a number:","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19");
		$body_repeat 		= array("no-repeat","repeat-x","repeat-y","repeat");
		$body_pos 			= array("top left","top center","top right","center left","center center","center right","bottom left","bottom center","bottom right");
		
		// Image Alignment radio box
		$of_options_thumb_align = array("alignleft" => "Left","alignright" => "Right","aligncenter" => "Center"); 
		
		// Image Links to Options
		$of_options_image_link_to = array("image" => "The Image","post" => "The Post"); 
        
        //Background Repeat
        $of_options_repeat =array("Repeat"=>"Repeat","no-repeat"=>"No-repeat","repeat-x"=>"Repeat-x","repeat-y"=>"Repeat-y");
        //Background Attachment


/*-----------------------------------------------------------------------------------*/
/* The Options Array */
/*-----------------------------------------------------------------------------------*/

// Set the Options Array
global $of_options;
$of_options = array();

$of_options[] = array( 	"name" 		=> "General Settings",
						"type" 		=> "heading"
				);
					

$of_options[] = array( 	"name" 		=> "Site Logo",
						"desc" 		=> "Enter an URL or upload an image for the logo.",
						"id" 		=> "gdx_logo",
						// Use the shortcodes [site_url] or [site_url_secure] for setting default URLs
						"std" 		=> "",
						"type" 		=> "upload"
				);

$of_options[] = array( 	"name" 		=> "Favicon",
						"desc" 		=> "Enter an URL or upload an image for the Favicon Icon.",
						"id" 		=> "gdx_avicon",
						// Use the shortcodes [site_url] or [site_url_secure] for setting default URLs
						"std" 		=> "",
						"type" 		=> "upload"
				);

$of_options[] = array( 	"name" 		=> "Footer Text",
						"desc" 		=> "You can use the following shortcodes in your footer text: [wp-link] [theme-link] [loginout-link] [blog-title] [blog-link] [the-year]",
						"id" 		=> "gdx_footer",
						"std" 		=> "",
						"type" 		=> "textarea"
				);
  ///////              
/*

*/					
///////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////
				
$of_options[] = array( 	"name" 		=> "Styling Options",
						"type" 		=> "heading"
				);
				
$of_options[] = array( 	"name" 		=> "Theme Stylesheet",
						"desc" 		=> "Select your themes alternative color scheme.",
						"id" 		=> "gdx_stylesheet",
						"std" 		=> "default.css",
						"type" 		=> "select",
						"options" 	=> $alt_stylesheets
				);
				
$of_options[] = array( 	"name" 		=> "Background Color",
						"desc" 		=> "Pick a background color for the theme (default: #fff).",
						"id" 		=> "gdx_background_color",
						"std" 		=> "",
						"type" 		=> "color"
				);
                
$of_options[] = array( 	"name" 		=> "Background Image ",
						"desc" 		=> "Upload images Background.",
						"id" 		=> "gdx_backgroud_image",
						// Use the shortcodes [site_url] or [site_url_secure] for setting default URLs
						"std" 		=> "",
						"type" 		=> "upload"
				);
$of_options[] = array( 	"name" 		=> "Backgroud Repeat",
						"desc" 		=> "Select option.",
						"id" 		=> "gdx_backgroud_repeat",
						"std" 		=> "No-repeat",
						"type" 		=> "select",
						"options" 	=> $of_options_repeat
				); 
$of_options[] = array( 	"name" 		=> "Background Attachment",
						"desc" 		=> "",
						"id" 		=> "gdx_backgroud_attachment",
						"type" 		=> "select",
						"options" 	=> array('Scroll'=>"Scroll","Fixed"=>"Fixed")
				);              
                              			
$of_options[] = array( 	"name" 		=> "Main color",
						"desc" 		=> "Main color (default: #fff).",
						"id" 		=> "gdx_main_color",
						"std" 		=> "",
						"type" 		=> "color"
				);
				
				
$of_options[] = array( 	"name" 		=> "Custom CSS",
						"desc" 		=> "Quickly add some CSS to your theme by adding it to this block.",
						"id" 		=> "gdx_custom_css",
						"std" 		=> "",
						"type" 		=> "textarea"
				);
				
$of_options[] = array( 	"name" 		=> "Social Share",
						"type" 		=> "heading"
				);
				
$of_options[] = array( 	"name" 		=> "Social Share",
						"desc" 		=> "Switch OFF with hidden options. ;)",
						"id" 		=> "gdx_social",
						"std" 		=> 0,
						"folds"		=> 1,
						"type" 		=> "switch"
				);
				
$of_options[] = array( 	"name" 		=> "RSS Feed",
						"desc" 		=> "RSS Feed",
						"id" 		=> "gdx_rss",
						"std" 		=> "#",
						"fold" 		=> "gdx_social", /* the switch hook */
						"type" 		=> "text"
				);
				
$of_options[] = array( 	"name" 		=> "Twitter",
						"desc" 		=> "Twitter",
						"id" 		=> "gdx_twitter",
						"std" 		=> "#",
						"fold" 		=> "gdx_social", /* the switch hook */
						"type" 		=> "text"
				);
$of_options[] = array( 	"name" 		=> "Facebook",
						"desc" 		=> "Facebook",
						"id" 		=> "gdx_facebook",
						"std" 		=> "#",
						"fold" 		=> "gdx_social", /* the switch hook */
						"type" 		=> "text"
				);
$of_options[] = array( 	"name" 		=> "Google+",
						"desc" 		=> "Google+",
						"id" 		=> "gdx_google",
						"std" 		=> "#",
						"fold" 		=> "gdx_social", /* the switch hook */
						"type" 		=> "text"
				);
$of_options[] = array( 	"name" 		=> "Pinterest",
						"desc" 		=> "Pinterest",
						"id" 		=> "gdx_pinterest",
						"std" 		=> "#",
						"fold" 		=> "gdx_social", /* the switch hook */
						"type" 		=> "text"
				);                 

				
//Advanced Settings
$of_options[] = array( 	"name" 		=> "Typography",
						"type" 		=> "heading"
				);
				
$of_options[] = array( 	"name" 		=> "Menu Font",
						"desc" 		=> "Specify the menu font properties",
						"id" 		=> "gdx_menu_font",
						"std" 		=> array('size' => '12px','face' => 'arial','style' => 'normal','color' => '#000000'),
						"type" 		=> "typography"
				);  
$of_options[] = array( 	"name" 		=> "Heading Font ",
						"desc" 		=> "Specify the heading font properties",
						"id" 		=> "gdx_heading_font",
						"std" 		=> array('size' => '12px','face' => 'arial','style' => 'normal','color' => '#000000'),
						"type" 		=> "typography"
				);  
                        
$of_options[] = array( 	"name" 		=> "Body Font",
						"desc" 		=> "Specify the body font properties",
						"id" 		=> "gdx_body_font",
						"std" 		=> array('size' => '12px','face' => 'arial','style' => 'normal','color' => '#000000'),
						"type" 		=> "typography"
				);  
//Advertisement  	
$of_options[] = array( 	"name" 		=> "Advertisemen",
						"type" 		=> "heading"
				);	
 $of_options[] = array( 	"name" 		=> "Advertisemen",
						"desc" 		=> "Switch OFF with hidden options",
						"id" 		=> "gdx_advertisemen",
						"std" 		=> 0,
						"folds"		=> 1,
						"type" 		=> "switch"
				);
				
$of_options[] = array( 	"name" 		=> "Advertisemen html",
						"desc" 		=> "Enter your HTML code for the header ads",
						"id" 		=> "gdx_gdx_advertisemen_html",
						"std" 		=> "",
						"fold" 		=> "gdx_advertisemen", /* the switch hook */
						"type" 		=> "textarea"
				);
				
             
                		
// Backup Options
$of_options[] = array( 	"name" 		=> "Backup Options",
						"type" 		=> "heading",
						"icon"		=> ADMIN_IMAGES . "6.png"
				);
				
$of_options[] = array( 	"name" 		=> "Backup and Restore Options",
						"id" 		=> "of_backup",
						"std" 		=> "",
						"type" 		=> "backup",
						"desc" 		=> 'You can use the two buttons below to backup your current options, and then restore it back at a later time. This is useful if you want to experiment on the options but would like to keep the old settings in case you need it back.',
				);
				
$of_options[] = array( 	"name" 		=> "Transfer Theme Options Data",
						"id" 		=> "of_transfer",
						"std" 		=> "",
						"type" 		=> "transfer",
						"desc" 		=> 'You can tranfer the saved options data between different installs by copying the text inside the text box. To import data from another install, replace the data in the text box with the one from another install and click "Import Options".',
				);
				
	}//End function: of_options()
}//End chack if function exists: of_options()
?>
